package com.aidansmeaton.weightmanager;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

/** The first activity in the app. */
public class RedditPostActivity extends Activity {
	
	private String link;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reddit_post_page);
        
        TextView titleTextView = (TextView) findViewById(R.id.reddit_row_title);
		TextView timeTextView = (TextView) findViewById(R.id.reddit_row_time);
		WebView description = (WebView) findViewById(R.id.web_engine);

		String data = getIntent().getStringExtra("Description");

		titleTextView.setText(Html.fromHtml(getIntent().getStringExtra("Title")));
		timeTextView.setText(getIntent().getStringExtra("Date"));
		
		description.getSettings().setJavaScriptEnabled(true);
		description.loadData(data, "text/html", "UTF-8");
		
		link = getIntent().getStringExtra("Link");
	}
    
    public void linkClick(View v){
		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
		startActivity(browserIntent);
	}
	
}